package com.itheima.config.filter;

import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;

/**
 * @program: Spring_day01_01_IOC入门程序
 * @description:
 * @author: xuejingjing
 * @create: 2021-08-01 20:09
 **/
public class MyTypeFilter implements TypeFilter {
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        //加载的类满足要求，匹配成功
        ClassMetadata classMetadata = metadataReader.getClassMetadata();
        String className = classMetadata.getClassName();
        System.out.println(className);//这句话打印出来的是spring加载的所有com.itheima的全类名

        if(className.equals("com.itheima.service.impl.UserServiceImpl")){
            return true;
        }

       return false; //放行
      //  return true;//表示所有的扫描都不能装载，false表示所有的都不拦截
    }
}
